package com.vogue.supplymall.common.domain.tool;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 用于检测当前是否为测试环境的辅助类
 * 
 * @author 崔岳
 *
 */
@Component
public class VerifyEnvironmentBean {

	/**当前运行环境是否为测试环境*/
	public static Boolean isTest = false;
	/**哪些平台分区是用于演示的测试性分区*/
	public static List<String> platDemoList = new ArrayList<>();
    
	@Value("${system.runner.istest}")
	public void setIsTest(Boolean isTest) {
		VerifyEnvironmentBean.isTest = isTest;
	}

	@Value("${system.platname.demo}") 
	public void setPlatDemoList(String platDemoList) {
		if(platDemoList != null) {
			VerifyEnvironmentBean.platDemoList = Arrays.asList(platDemoList.split(","));
		}		
	}

	/**
	 * 获取是否过期的标志
	 * @param platName	平台分区编号
	 * @return
	 */
	public static Boolean getTestFlag(String platName) {
		return (isTest || platDemoList.contains(platName));
	}
	 
}
